package cn.wolfcode.web.controller;

import cn.wolfcode.domain.MessageReply;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageBoardService;
import cn.wolfcode.service.IMessageReplyService;
import cn.wolfcode.util.RequiredPermission;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/messageReply")
public class MessageReplyController {

    @Autowired
    private IMessageReplyService messageReplyService;

    @Autowired
    private IMessageBoardService messageBoardService;

    //处理查询所有回复消息的请求 /messageReply/list
    @RequestMapping("/detail")
    public String list(Model model, Long boardId){

        model.addAttribute("messageBoard",messageBoardService.get(boardId));

        List<MessageReply> replyPageInfo = messageReplyService.selectById(boardId);//查出数据
        model.addAttribute("replyPageInfo",replyPageInfo);

        int size = replyPageInfo.size();
        model.addAttribute("size",size);


        //model拿到数据后与jsp合并渲染成HTML格式，展现在页面上
        return "message/detail";  // /WEB-INF/views/messageReply/list.ftl
    }

}
